#ifndef TERMINAL_CMD_H
#define TERMINAL_CMD_H
    #include<stddef.h>

    #define CMD_LINE_LEN 256
    #define MAX_ARG_NUM 16
    #ifndef MAX_PATH_LEN
    #define MAX_PATH_LEN 256
    #endif 

    #define CMD_BUFF_NUM 20

    typedef struct 
    {
        int flags;
        char cmdbuff[CMD_LINE_LEN];
    }cmd_buff_t;

    typedef struct 
    {   
        char cwd_cache[MAX_PATH_LEN];
        char cmd_line[CMD_LINE_LEN];
        cmd_buff_t cmd_buff[CMD_BUFF_NUM];

        char *cmd_pos;
        int cmd_len;

        int cur_cmd_buff;
        int next_cmd_buff;
    }cmd_man_t;

    #define SIZE_CMD_MAX sizeof(cmd_man_t)

    extern cmd_man_t *cmdman;

    int terminal_cmdman_init();
    void exit_cmdman();
    int cmdline_set(char *buff,int bufflen);
    void cmd_buff_select(int dir);
    void cmd_buff_copy();
    void cmd_buff_insert();
    int cmdline_check();
    void printf_cmdline();
#endif